clear
import excel "C:\Users\Public\Documents\DoFiles\doFiles_TransmissionModel\Matlab\CES\Tables\table_Figure5.xlsx", sheet("Sheet1") firstrow
rename Row iso
rename table_data_1 HighTol_het
rename table_data_2 HighTol_CspecificHom
rename table_data_3 HighTol_gran_residual
rename table_data_3 HighTol_AllHom
g HighTol_gran = HighTol_gran_residual/HighTol_het
egen tot=sum(HighTol_het)
g weight = HighTol_het/tot

g Cspecific_ratio =  HighTol_CspecificHom/ HighTol_het

tw (scatter Cspecific_ratio HighTol_gran, mlabel(iso) scheme(s1mono) xtitle("Granular residual") ytitle("Hom/Het ratio")) (lfit Cspecific_ratio HighTol_gran)


tw (scatter Cspecific_ratio HighTol_gran  , mlabel(iso)   mcolor(blue) scheme(s1mono) xtitle("{&Gamma}{sup:m}/d ln Y{sup:m}") ytitle("d ln Y{sup:HOM,m}/d ln Y{sup:m}")) (lfit Cspecific_ratio HighTol_gran , legend(off) lw(thick) lcolor(red))
gr export "C:\Users\Public\Documents\DoFiles\doFiles_TransmissionModel\Matlab\CES\Figures\Fig5_UnWeighted.eps", as(eps) replace
* mcolor(blue)
tw (scatter Cspecific_ratio HighTol_gran [pw= weight] , msymbol(Oh) mcolor(blue)  scheme(s1mono) xtitle("{&Gamma}{sup:m}/d ln Y{sup:m}") ytitle("d ln Y{sup:HOM,m}/d ln Y{sup:m}")) (lfit Cspecific_ratio HighTol_gran [pw= weight], legend(off) lw(thick) lcolor(red))
gr export "C:\Users\Public\Documents\DoFiles\doFiles_TransmissionModel\Matlab\CES\Figures\Fig5_Weighted.eps", as(eps) replace

